package test;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Week09_06_01 {

		public static List convertStringToList(String line) 
		{
			String[] str = line.split(" +");
			List<String> list = new ArrayList<String>();
			for(String e:str)
				list.add(e);
			return list;
		}
		
		public static void remove(List list, String str)
		{
			for(int i=list.size()-1;i>=0;i--)
			{
				if(list.get(i).equals(str))
					list.remove(i);
			}
		}
		
	    /*covnertStringToList函数代码*/   
			
	    /*remove函数代码*/
			
	     public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        while(sc.hasNextLine()){
	            List<String> list = convertStringToList(sc.nextLine());
	            System.out.println(list);
	            String word = sc.nextLine();
	            remove(list,word);
	            System.out.println(list);
	        }
	        sc.close();
	    }

	}